#!/usr/bin/env python
# -*- coding: utf-8 -*-

import codecs
import copy
import csv
import json
import logging
import logging.config
import math
import os
from os import path
import random
import re
import sqlite3
import sys
import warnings
from collections import OrderedDict
from datetime import date, datetime, timedelta
from pathlib import Path
from time import sleep

import requests
from lxml import etree
from requests.adapters import HTTPAdapter
from tqdm import tqdm

import const
from util import csvutil
from util.dateutil import convert_to_days_ago
from util.notify import push_deer



# 如果日志文件夹不存在，则创建
if not os.path.isdir("log/"):
    os.makedirs("log/")
logging_path = os.path.split(os.path.realpath(__file__))[0] + os.sep + "logging.conf"
logging.config.fileConfig(logging_path)
logger = logging.getLogger("feilSearch")


def scaner_file (url):
        #遍历当前路径下所有文件
        file  = os.listdir(url)
        for f in file:
            real_url = path.join(url, f)
            if path.isfile(real_url):
                if path.getsize(real_url) < 1000:
                    dirs = real_url.split("/")

                    print(dirs[8])
                    print("https://pbs.twimg.com/media/"+dirs[9])
                    #print(path.abspath(real_url))
                # 如果是文件，则以绝度路径的方式输出
            elif path.isdir(real_url):
                # 如果是目录，则是地柜调研自定义函数 scaner_file (url)进行多次
                scaner_file(real_url)
            else:

                print("其他情况")
                pass

            #print(real_url)


if __name__ == "__main__":
        scaner_file("/Volumes/move/phone/.phone/.twitter/twitter/photo")
